package com.ysd.Servlet;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


import com.ysd.dao.impl.ChanPinXiangQingDaoimpl;
import com.ysd.dao.impl.ChanPinXiangQingNeiRongDaoimpl;
import com.ysd.dao.impl.ChuangShiRenDaoimpl;
import com.ysd.dao.impl.FenLeiBiaoDaoimpl;
import com.ysd.dao.impl.GongShiTuPianDaoimpl;
import com.ysd.dao.impl.XiYangYangChaoShiDaoimpl;
import com.ysd.dao.impl.XiangXiXinWenDaoImpl;
import com.ysd.dao.impl.XinWenDaoimpl;

import com.ysd.entity.ChanPinXiangQing;
import com.ysd.entity.ChuangShiRen;
import com.ysd.entity.FenLeiBiao;
import com.ysd.entity.GongShiTuPian;
import com.ysd.entity.XiYangYangChaoShi;
import com.ysd.entity.XiangXiXinWen;
import com.ysd.entity.XinWen;
public class HomeServlet extends HttpServlet {
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		HttpSession session=request.getSession();
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		
		XiYangYangChaoShiDaoimpl xyycsd=new  XiYangYangChaoShiDaoimpl();//获得喜洋洋超市的实现类
		XiYangYangChaoShi xyycs=xyycsd.getXiYangYangCahoShi();//获得喜洋洋超市的实现类打点获得喜洋洋超市的表
		session.setAttribute("xyycs", xyycs);//存到session
		
		GongShiTuPianDaoimpl gstpd=new GongShiTuPianDaoimpl();//获得公司图表的实现类
		GongShiTuPian gstp=gstpd.getGongShiTuPian(); //获得公司表的实现类打点获得公司表的表
		session.setAttribute("gstp", gstp);//存数据到session

		
		ChuangShiRenDaoimpl csrd=new ChuangShiRenDaoimpl();//获得创始人的实现类
		ArrayList<ChuangShiRen> csr=csrd.getChuagShiRen();//获得创始人的数据
		request.setAttribute("csr", csr);//存数据到下个页面
		
		FenLeiBiaoDaoimpl flbd=new FenLeiBiaoDaoimpl();//获得产品分类的实现类
		ArrayList<FenLeiBiao> flb=flbd.getFenLeiBiao();//通过获得产品分类的显现类的数据
		request.setAttribute("flb", flb);//存数据到下个页面
	
		
		ChanPinXiangQingDaoimpl cpxqDao=new ChanPinXiangQingDaoimpl();//获得产品详情的实现类
		ArrayList<ChanPinXiangQing> cpxqlist=cpxqDao.getJingPingAnLi();//通过实现类获得数据
		request.setAttribute("cpxqlist", cpxqlist);
		
		ArrayList<ChanPinXiangQing> jxxwTu=cpxqDao.getJingXuanXinWenTuPian();//获得数据
		request.setAttribute("jxxwTu", jxxwTu);
		
		
		
		XiangXiXinWenDaoImpl xxxwDao=new XiangXiXinWenDaoImpl();
		ArrayList<XiangXiXinWen> xxxwList=xxxwDao.getXinWenJingXuan();
		request.setAttribute("xxxwList", xxxwList);
		
		
		
		request.getRequestDispatcher("index.jsp").forward(request, response);
		
	}
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
